﻿#include "hzpch.h"
#include "Buffer.h"

#include "SourceCode/Renderer/Renderer.h"
#include "SourceCode/Platforms/OpenGL/OpenGLBuffer.h"

namespace Hazal
{
	Ref<CVertexBuffer> CVertexBuffer::Create(float* pVertices, uint32_t size)
	{
		switch (CRenderer::GetAPI())
		{
		case CRendererAPI::API::None:
		{
			HZ_ASSERT(false, "RendererAPI::None is not supported!");
			return nullptr;
		}
		case CRendererAPI::API::OpenGL:
		{
			return CreateRef<COpenGLVertexBuffer>(pVertices, size);
		}
		break;
		default:
			break;
		}

		HZ_ASSERT(false, "No renderer API is supported!");
		return nullptr;
	}

	Ref<CVertexBuffer> CVertexBuffer::Create(uint32_t unSize)
	{
		switch (CRenderer::GetAPI())
		{
		case CRendererAPI::API::None:
		{
			HZ_ASSERT(false, "RendererAPI::None is not supported!");
			return nullptr;
		}
		case CRendererAPI::API::OpenGL:
		{
			return CreateRef<COpenGLVertexBuffer>(unSize);
		}
		break;
		default:
			break;
		}

		HZ_ASSERT(false, "No renderer API is supported!");
		return nullptr;
	}


	CIndexBuffer* CIndexBuffer::Create(uint32_t* pIndices, uint32_t unCount)
	{
		switch (CRenderer::GetAPI())
		{
		case CRendererAPI::API::None:
		{
			HZ_ASSERT(false, "RendererAPI::None is not supported!");
			return nullptr;
		}
		case CRendererAPI::API::OpenGL:
		{
			return new COpenGLIndexBuffer(pIndices, unCount);
		}
		break;
		default:
			break;
		}

		HZ_ASSERT(false, "No renderer API is supported!");
		return nullptr;
	}
}